package com.zhuoshi.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.zhuoshi.entity.PayMentTypeCustom;
import com.zhuoshi.entity.PayMentTypeQueryVo;
import com.zhuoshi.service.PayMentTypeService;

@Controller
@RequestMapping("payMentType")
public class PayMentTypeController {
	@Autowired
	private PayMentTypeService payMentTypeService;
	
//	查询所有付款方式
	@RequestMapping("selectPayMentTypeList")
	public ModelAndView selectPayMentTypeList() throws Exception{
		List<PayMentTypeCustom> payMentTypes=payMentTypeService.selectPayMentTypeList();
		ModelAndView modelAndView=new ModelAndView();
		modelAndView.addObject("payMentTypes",payMentTypes);
		modelAndView.setViewName("/Admin/second/paymentTypeList.jsp");
		return modelAndView;
	}
	
//	查询所有付款方式(开盘导入付款方式)
	@RequestMapping("selectPayMentTypeListAddPayMentType")
	public ModelAndView selectPayMentTypeListAddPayMentType() throws Exception{
		List<PayMentTypeCustom> payMentTypes=payMentTypeService.selectPayMentTypeList();
		ModelAndView modelAndView=new ModelAndView();
		modelAndView.addObject("payMentTypes",payMentTypes);
		modelAndView.setViewName("/Admin/second/fuKuanFangShi.jsp");
		return modelAndView;
	}
	
//	删除付款方式（单个和批量都可以）
	@RequestMapping("deletePayMentTypeList")
	public ModelAndView deletePayMentTypeList(Integer[] ids) throws Exception{
		Integer rows=payMentTypeService.deletePayMentTypeList(ids);
		ModelAndView modelAndView=new ModelAndView();
		modelAndView.setViewName("redirect:selectPayMentTypeList.action");
		return modelAndView;
	}
	

	
//	添加付款方式
	@RequestMapping("addPayMentType")
	public ModelAndView addPayMentType(PayMentTypeQueryVo payMentTypeQueryVo) throws Exception{
		Integer rows=payMentTypeService.addPayMentType(payMentTypeQueryVo);
		ModelAndView modelAndView=new ModelAndView();
		modelAndView.setViewName("redirect:selectPayMentTypeList.action");
		return modelAndView;
	}
	
//	根据ID查付款方式
	@RequestMapping("selectPayMentTypeById")
	public ModelAndView selectPayMentTypeById(Integer id) throws Exception{
		PayMentTypeCustom payMentTypeCustom=payMentTypeService.selectPayMentTypeById(id);
		ModelAndView modelAndView=new ModelAndView();
		modelAndView.addObject("payMentTypeCustom",payMentTypeCustom);
		modelAndView.setViewName("/Admin/second/updateFukuanfangshi.jsp");
		return modelAndView;
	}
	
//	修改付款
	@RequestMapping("updatePayMentType")
	public ModelAndView updatePayMentType(PayMentTypeQueryVo payMentTypeQueryVo) throws Exception{
		System.out.println("deadid:"+payMentTypeQueryVo.getPayMentTypeCustom().getDeadline().getId());
		payMentTypeService.updatePayMentType(payMentTypeQueryVo);
		
		ModelAndView modelAndView=new ModelAndView();
		modelAndView.setViewName("redirect:selectPayMentTypeList.action");
		return modelAndView;
	}
}
